<? //include/CUSTOMERS_session.php

include("CUSTOMERS.php");

require_once'../include/database.php';
$conn = new Connection();
$conn->NewConnection('localhost','ecommerce','root','batavia');
class SessionCUSTOMERS { 


 
 function find($id){
    
   global $conn;
   
   $query = "select CustomerID,FirstName,LastName,Class,Room,Building,Address1,Address2,City,State,PostalCode,Country,Phone,Email,VoiceMail,Passwords,CreditCard,CreditCardTypeID,CardExpMo,CardExpYr,BillingAddress,BillingCity,BillingRegion,BillingPostalCode,BillingCountry,ShipAddress,SHipCity,ShipRegion,ShipPostalCode,ShipCountry,DateEntered from CUSTOMERS where CustomerID='$id'";
   
   $run = mysql_query($query) or die(mysql_error());
   
   $row = mysql_fetch_array($run, MYSQL_ASSOC);
   
   $numRow = mysql_numrows($run);
   
   if($numRow)
   
   {
   
   $this->CUSTOMERS= new CUSTOMERS();


   
	$this->CUSTOMERS->setCustomerID($row['CustomerID']);

 
	$this->CUSTOMERS->setFirstName($row['FirstName']);

 
	$this->CUSTOMERS->setLastName($row['LastName']);

 
	$this->CUSTOMERS->setClass($row['Class']);

 
	$this->CUSTOMERS->setRoom($row['Room']);

 
	$this->CUSTOMERS->setBuilding($row['Building']);

 
	$this->CUSTOMERS->setAddress1($row['Address1']);

 
	$this->CUSTOMERS->setAddress2($row['Address2']);

 
	$this->CUSTOMERS->setCity($row['City']);

 
	$this->CUSTOMERS->setState($row['State']);

 
	$this->CUSTOMERS->setPostalCode($row['PostalCode']);

 
	$this->CUSTOMERS->setCountry($row['Country']);

 
	$this->CUSTOMERS->setPhone($row['Phone']);

 
	$this->CUSTOMERS->setEmail($row['Email']);

 
	$this->CUSTOMERS->setVoiceMail($row['VoiceMail']);

 
	$this->CUSTOMERS->setPasswords($row['Passwords']);

 
	$this->CUSTOMERS->setCreditCard($row['CreditCard']);

 
	$this->CUSTOMERS->setCreditCardTypeID($row['CreditCardTypeID']);

 
	$this->CUSTOMERS->setCardExpMo($row['CardExpMo']);

 
	$this->CUSTOMERS->setCardExpYr($row['CardExpYr']);

 
	$this->CUSTOMERS->setBillingAddress($row['BillingAddress']);

 
	$this->CUSTOMERS->setBillingCity($row['BillingCity']);

 
	$this->CUSTOMERS->setBillingRegion($row['BillingRegion']);

 
	$this->CUSTOMERS->setBillingPostalCode($row['BillingPostalCode']);

 
	$this->CUSTOMERS->setBillingCountry($row['BillingCountry']);

 
	$this->CUSTOMERS->setShipAddress($row['ShipAddress']);

 
	$this->CUSTOMERS->setSHipCity($row['SHipCity']);

 
	$this->CUSTOMERS->setShipRegion($row['ShipRegion']);

 
	$this->CUSTOMERS->setShipPostalCode($row['ShipPostalCode']);

 
	$this->CUSTOMERS->setShipCountry($row['ShipCountry']);

 
	$this->CUSTOMERS->setDateEntered($row['DateEntered']);

 
}
return $this->CUSTOMERS;
}

function insert($CUSTOMERS){
	global $conn;
	$query = "insert into CUSTOMERS(CustomerID,FirstName,LastName,Class,Room,Building,Address1,Address2,City,State,PostalCode,Country,Phone,Email,VoiceMail,Passwords,CreditCard,CreditCardTypeID,CardExpMo,CardExpYr,BillingAddress,BillingCity,BillingRegion,BillingPostalCode,BillingCountry,ShipAddress,SHipCity,ShipRegion,ShipPostalCode,ShipCountry,DateEntered) values('".$CUSTOMERS->getCustomerID()."','".$CUSTOMERS->getFirstName()."','".$CUSTOMERS->getLastName()."','".$CUSTOMERS->getClass()."','".$CUSTOMERS->getRoom()."','".$CUSTOMERS->getBuilding()."','".$CUSTOMERS->getAddress1()."','".$CUSTOMERS->getAddress2()."','".$CUSTOMERS->getCity()."','".$CUSTOMERS->getState()."','".$CUSTOMERS->getPostalCode()."','".$CUSTOMERS->getCountry()."','".$CUSTOMERS->getPhone()."','".$CUSTOMERS->getEmail()."','".$CUSTOMERS->getVoiceMail()."','".$CUSTOMERS->getPasswords()."','".$CUSTOMERS->getCreditCard()."','".$CUSTOMERS->getCreditCardTypeID()."','".$CUSTOMERS->getCardExpMo()."','".$CUSTOMERS->getCardExpYr()."','".$CUSTOMERS->getBillingAddress()."','".$CUSTOMERS->getBillingCity()."','".$CUSTOMERS->getBillingRegion()."','".$CUSTOMERS->getBillingPostalCode()."','".$CUSTOMERS->getBillingCountry()."','".$CUSTOMERS->getShipAddress()."','".$CUSTOMERS->getSHipCity()."','".$CUSTOMERS->getShipRegion()."','".$CUSTOMERS->getShipPostalCode()."','".$CUSTOMERS->getShipCountry()."','".$CUSTOMERS->getDateEntered()."')";
 
 $parse=mysql_query($query);

 }
 
 function findall(){
	$query = "select CustomerID,FirstName,LastName,Class,Room,Building,Address1,Address2,City,State,PostalCode,Country,Phone,Email,VoiceMail,Passwords,CreditCard,CreditCardTypeID,CardExpMo,CardExpYr,BillingAddress,BillingCity,BillingRegion,BillingPostalCode,BillingCountry,ShipAddress,SHipCity,ShipRegion,ShipPostalCode,ShipCountry,DateEntered from CUSTOMERS";
	$parse=mysql_query($query);
	$datas = array();
	while($row=mysql_fetch_assoc($parse))
	{
		$data = array();$data['CustomerID'] = $row['CustomerID'];
		$data['FirstName'] = $row['FirstName'];
		$data['LastName'] = $row['LastName'];
		$data['Class'] = $row['Class'];
		$data['Room'] = $row['Room'];
		$data['Building'] = $row['Building'];
		$data['Address1'] = $row['Address1'];
		$data['Address2'] = $row['Address2'];
		$data['City'] = $row['City'];
		$data['State'] = $row['State'];
		$data['PostalCode'] = $row['PostalCode'];
		$data['Country'] = $row['Country'];
		$data['Phone'] = $row['Phone'];
		$data['Email'] = $row['Email'];
		$data['VoiceMail'] = $row['VoiceMail'];
		$data['Passwords'] = $row['Passwords'];
		$data['CreditCard'] = $row['CreditCard'];
		$data['CreditCardTypeID'] = $row['CreditCardTypeID'];
		$data['CardExpMo'] = $row['CardExpMo'];
		$data['CardExpYr'] = $row['CardExpYr'];
		$data['BillingAddress'] = $row['BillingAddress'];
		$data['BillingCity'] = $row['BillingCity'];
		$data['BillingRegion'] = $row['BillingRegion'];
		$data['BillingPostalCode'] = $row['BillingPostalCode'];
		$data['BillingCountry'] = $row['BillingCountry'];
		$data['ShipAddress'] = $row['ShipAddress'];
		$data['SHipCity'] = $row['SHipCity'];
		$data['ShipRegion'] = $row['ShipRegion'];
		$data['ShipPostalCode'] = $row['ShipPostalCode'];
		$data['ShipCountry'] = $row['ShipCountry'];
		$data['DateEntered'] = $row['DateEntered'];
		$datas[] = $data;
	 }
	return $datas;
	}
	function delete($CUSTOMERS){
	$query = "delete from CUSTOMERS where CustomerID= '".$CUSTOMERS->getCustomerID()."'";
	$parse=mysql_query($query);
	return $parse;

	}
	
	function update($CUSTOMERS){
	$query = "update CUSTOMERS set FirstName= '".$CUSTOMERS->getFirstName()."',LastName= '".$CUSTOMERS->getLastName()."',Class= '".$CUSTOMERS->getClass()."',Room= '".$CUSTOMERS->getRoom()."',Building= '".$CUSTOMERS->getBuilding()."',Address1= '".$CUSTOMERS->getAddress1()."',Address2= '".$CUSTOMERS->getAddress2()."',City= '".$CUSTOMERS->getCity()."',State= '".$CUSTOMERS->getState()."',PostalCode= '".$CUSTOMERS->getPostalCode()."',Country= '".$CUSTOMERS->getCountry()."',Phone= '".$CUSTOMERS->getPhone()."',Email= '".$CUSTOMERS->getEmail()."',VoiceMail= '".$CUSTOMERS->getVoiceMail()."',Passwords= '".$CUSTOMERS->getPasswords()."',CreditCard= '".$CUSTOMERS->getCreditCard()."',CreditCardTypeID= '".$CUSTOMERS->getCreditCardTypeID()."',CardExpMo= '".$CUSTOMERS->getCardExpMo()."',CardExpYr= '".$CUSTOMERS->getCardExpYr()."',BillingAddress= '".$CUSTOMERS->getBillingAddress()."',BillingCity= '".$CUSTOMERS->getBillingCity()."',BillingRegion= '".$CUSTOMERS->getBillingRegion()."',BillingPostalCode= '".$CUSTOMERS->getBillingPostalCode()."',BillingCountry= '".$CUSTOMERS->getBillingCountry()."',ShipAddress= '".$CUSTOMERS->getShipAddress()."',SHipCity= '".$CUSTOMERS->getSHipCity()."',ShipRegion= '".$CUSTOMERS->getShipRegion()."',ShipPostalCode= '".$CUSTOMERS->getShipPostalCode()."',ShipCountry= '".$CUSTOMERS->getShipCountry()."',DateEntered= '".$CUSTOMERS->getDateEntered()."' where CustomerID= '".$CUSTOMERS->getCustomerID()."'";
$parse=mysql_query($query);

}


}
 //include/CUSTOMERS_session.php